package com.yic.module.qms.dal.mysql.inspectschemeentry;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.qms.dal.dataobject.inspectschemeentry.InspectSchemeEntryDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.qms.controller.admin.inspectschemeentry.vo.*;

/**
 * 检验方案检验项关联 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface InspectSchemeEntryMapper extends BaseMapperX<InspectSchemeEntryDO> {

    default PageResult<InspectSchemeEntryDO> selectPage(InspectSchemeEntryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InspectSchemeEntryDO>()
                .eqIfPresent(InspectSchemeEntryDO::getSchemeId, reqVO.getSchemeId())
                .eqIfPresent(InspectSchemeEntryDO::getEntryId, reqVO.getEntryId())
                .orderByDesc(InspectSchemeEntryDO::getId));
    }

    default List<InspectSchemeEntryDO> selectList(InspectSchemeEntryExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InspectSchemeEntryDO>()
                .eqIfPresent(InspectSchemeEntryDO::getSchemeId, reqVO.getSchemeId())
                .eqIfPresent(InspectSchemeEntryDO::getEntryId, reqVO.getEntryId())
                .orderByDesc(InspectSchemeEntryDO::getId));
    }

    default InspectSchemeEntryDO selectBySchemeAndEntry(Long schemeId, Long entryId) {
        return selectOne(new LambdaQueryWrapperX<InspectSchemeEntryDO>()
                .eq(InspectSchemeEntryDO::getSchemeId, schemeId)
                .eq(InspectSchemeEntryDO::getEntryId, entryId));
    }

    default List<InspectSchemeEntryDO> selectListBySchemeId(Long schemeId) {
        return selectList(new LambdaQueryWrapperX<InspectSchemeEntryDO>()
                .eq(InspectSchemeEntryDO::getSchemeId, schemeId));
    }

    default int deleteBySchemeId(Long schemeId) {
        return delete(new LambdaQueryWrapperX<InspectSchemeEntryDO>()
                .eq(InspectSchemeEntryDO::getSchemeId, schemeId));
    }
}
